home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Development Tools & Languages / Dylan Related / Marlais / MacMarlais 0.5.9d46 / Examples / random-test.dyl < prev    next >
Encoding:
Text File  |  1995-02-09  |  919 b   |  31 lines  |  [TEXT/Mrls]

  1. module:        dylan-user
  2. author:        Patrick C. Beard <beard@cs.ucdavis.edu>
  3. synopsis:        short demo of random module.
  4. copyright:    Copyright (C) 1994, Patrick C. Beard. All rights reserved.
  5.  
  6. //
  7. //    random-test.dyl
  8. //
  9. //    before running this file, load "Random.dyl" from the Marlais menu.
  10. //
  11.  
  12. begin
  13. //    set-module(Random);    // so we can use the Random module.
  14.  
  15.     local method test-dist(dist :: <random-distribution>)
  16.         princ(object-class(dist));
  17.         for (i from 1 to 10)
  18.             princ(random(dist));
  19.         end for;
  20.     end test-dist;
  21.     
  22.     test-dist(make(<unit-uniform-distribution>));
  23.     test-dist(make(<real-uniform-distribution>, from: 1.0, to: 10.0));
  24.     test-dist(make(<integer-uniform-distribution>, from: 1, to: 10));
  25.     test-dist(make(<exponential-distribution>));
  26.     test-dist(make(<normal-distribution>));
  27.     
  28.     princ("computing chi square of integer distribution from 1 to 10.");
  29.     chi-square(make(<integer-uniform-distribution>, from: 1, to: 10));
  30. end;
  31.